package com.IronLogistic.SqlServer;

import java.sql.*;

public class GestorJdbc
{
  Connection conn;

  /*public static void main(String[] args)
  {
    new BasicJDBCDemo();
  }*/
 
   /*******************************************************************/
 	/****************conexion*******************************************/
 	/**
 	 * @throws ClassNotFoundException ****************************************************************/
  public void conectar() throws SQLException, ClassNotFoundException
  {

      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      String url = "jdbc:sqlserver://127.0.0.1;database=Iron_Logistic;username=sa;password=123456789;";
      conn = DriverManager.getConnection(url);
      

  }
  /*private void doTests()
  {
    doSelectTest();

    doInsertTest();  doSelectTest();
    doUpdateTest();  doSelectTest();
    doDeleteTest();  doSelectTest();
  }*/

  public void desconectar() throws SQLException
  {

		conn.close();

	  
  }

   /*******************************************************************/
 	/****************SELECT*********************************************/
 	/******************************************************************/

  public ResultSet doSelect(String psQuery) throws SQLException
  {
    System.out.println(psQuery);
    String sQuery = psQuery;

      Statement st = conn.createStatement();
      ResultSet rs = st.executeQuery(sQuery);
			return rs;

  }
   /*******************************************************************/
 	/****************INSERT*********************************************/
 	/******************************************************************/


  public void doInsert(String psInsert) throws SQLException
  {
    System.out.print(psInsert);

      Statement st = conn.createStatement();
      st.executeUpdate(psInsert);


  }

   /*******************************************************************/
 	/****************UPDATE*********************************************/
 	/******************************************************************/

  public void doUpdate(String psUpdate) throws SQLException
  {
    System.out.print(psUpdate);

      Statement st = conn.createStatement();
      st.executeUpdate(psUpdate);


  }
  
  
   /*******************************************************************/
 	/****************DELETE*********************************************/
 	/******************************************************************/  

  public void doDelete(String psUpdate) throws SQLException
  {
    System.out.print(psUpdate);

      Statement st = conn.createStatement();
      st.executeUpdate(psUpdate);

  }
}

